﻿@section style {
<style>
    html, body { height:100% }
</style>
}
<div id="menu_module" class="page">
    <datagrid ref="roles" :columns="gridColumns" :edit="editSetting" :dateable="false" :url="'@ViewBag.DataUrl'">
    </datagrid>
</div>
@section script {
    <script>
        var _flags = @Html.ToJson((List<JsonData<int>>)ViewData["Flags"]);
    var vm = new Vue({
        el: '#menu_module',
        data: {
            editSetting: { showAdd: true, delUrl: '@ViewBag.DelUrl', saveUrl: '@ViewBag.SaveUrl', autoload: true },
            gridData: [],
            gridColumns: [
                        { bind: 'Id', title: '编号', width:'50px' },
                        { bind: 'Name', title: '名称', width: '160px', editor: { type: 'text' } },
                        { bind: 'Url', title: '地址', editor: { type: 'text' }, width:'120px' },
                        { bind: 'Model', title: '模块名称', editor: { type: 'text' }, width:'100px' },
                        {
                            bind: 'Flags', title: '默认标识', width: '100px', format: function (val, data) {
                                if (!data.Flags) return '';
                                if (typeof (data.Flags) === "string")
                                    val = data.Flags.split(',');
                                let labels = [];
                                $.each(_flags, function () {
                                    if (val.exists(this.id))
                                        labels.push(this.text);
                                });
                                return labels.join(',');
                            }, editor: { type: 'select', data: _flags, multiple: true }
                        },
                        {
                            bind: 'DisableConfig', title: '模板', editor: { type: 'switch' }, width: '70px', format: function (val, data) {
                                return val?'<a class="am-badge am-badge-primary am-round">是</a>':'<a class="am-badge am-badge-default am-round">否</a>';
                            }
                        },
                        {
                            bind: 'Config', title: '配置', editor: { type: 'textarea' }, format: function (val) {
                                if (val)
                                    return val.length > 120 ? (val.substring(0, 120) + "...") : val;
                                return "";
                            }
                        }
            ]
        }
    });
    </script>
}